package com.lihang.rabbit1.dto.req;
import com.lihang.rabbit1.common.page.PageReq;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.time.LocalDateTime;

/**
 * 系统用户分页请求参数
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "用户分页请求参数")
public class SysUserPageReq extends PageReq {

    @Schema(description = "用户名")
    @Size(max = 50, message = "用户名长度不能超过50个字符")
    @Pattern(regexp = "^[a-zA-Z0-9_-]*$", message = "用户名只能包含英文、数字、下划线和中划线")
    private String username;

    @Schema(description = "昵称")
    @Size(max = 50, message = "昵称长度不能超过50个字符")
    private String nickname;

    @Schema(description = "真实姓名")
    @Size(max = 50, message = "真实姓名长度不能超过50个字符")
    @Pattern(regexp = "^[\\u4e00-\\u9fa5a-zA-Z]*$", message = "真实姓名只能包含中文和英文")
    private String realName;

    @Schema(description = "手机号")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
    private String phone;

    @Schema(description = "邮箱")
    @Email(message = "邮箱格式不正确")
    private String email;

    @Schema(description = "性别(0:男,1:女,2:未知) @see GenderEnum")
    @Min(value = 0, message = "性别不能小于0")
    @Max(value = 2, message = "性别不能大于2")
    private Integer gender;

    @Schema(description = "状态(0:禁用,1:启用) @see StatusEnum")
    @Min(value = 0, message = "状态不能小于0")
    @Max(value = 1, message = "状态不能大于1")
    private Integer status;

    @Schema(description = "开始时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;

    @Schema(description = "结束时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;
}